package cn.iocoder.yudao.module.biz.dal.mysql.dangerTicket;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.biz.dal.dataobject.dangerTicket.BizDangerTicketDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.biz.controller.admin.dangerTicket.vo.*;

/**
 * 危险作业票 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BizDangerTicketMapper extends BaseMapperX<BizDangerTicketDO> {

    default PageResult<BizDangerTicketDO> selectPage(BizDangerTicketPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BizDangerTicketDO>()
                .eqIfPresent(BizDangerTicketDO::getType, reqVO.getType())
                .eqIfPresent(BizDangerTicketDO::getNumber, reqVO.getNumber())
                .likeIfPresent(BizDangerTicketDO::getProjectName, reqVO.getProjectName())
                .likeIfPresent(BizDangerTicketDO::getDeptName, reqVO.getDeptName())
                .eqIfPresent(BizDangerTicketDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(BizDangerTicketDO::getPersonnelId, reqVO.getPersonnelId())
                .likeIfPresent(BizDangerTicketDO::getPersonnelName, reqVO.getPersonnelName())
                .eqIfPresent(BizDangerTicketDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BizDangerTicketDO::getIamge, reqVO.getIamge())
                .betweenIfPresent(BizDangerTicketDO::getStartTime, reqVO.getBeginStartTime(), reqVO.getEndStartTime())
                .betweenIfPresent(BizDangerTicketDO::getEndTime, reqVO.getBeginEndTime(), reqVO.getEndEndTime())
                .betweenIfPresent(BizDangerTicketDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(BizDangerTicketDO::getId));
    }

    default List<BizDangerTicketDO> selectList(BizDangerTicketExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BizDangerTicketDO>()
                .eqIfPresent(BizDangerTicketDO::getType, reqVO.getType())
                .eqIfPresent(BizDangerTicketDO::getNumber, reqVO.getNumber())
                .likeIfPresent(BizDangerTicketDO::getProjectName, reqVO.getProjectName())
                .likeIfPresent(BizDangerTicketDO::getDeptName, reqVO.getDeptName())
                .eqIfPresent(BizDangerTicketDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(BizDangerTicketDO::getPersonnelId, reqVO.getPersonnelId())
                .likeIfPresent(BizDangerTicketDO::getPersonnelName, reqVO.getPersonnelName())
                .eqIfPresent(BizDangerTicketDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BizDangerTicketDO::getIamge, reqVO.getIamge())
                .betweenIfPresent(BizDangerTicketDO::getStartTime, reqVO.getBeginStartTime(), reqVO.getEndStartTime())
                .betweenIfPresent(BizDangerTicketDO::getEndTime, reqVO.getBeginEndTime(), reqVO.getEndEndTime())
                .betweenIfPresent(BizDangerTicketDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(BizDangerTicketDO::getId));
    }

}
